package com.ls.socketio.bean;

import lombok.Getter;
import lombok.ToString;

import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;

/**
 * @author liShan
 * @date 2019/9/2 12:52
 */
@Getter
@ToString
public class ListClient {

    private CopyOnWriteArrayList<UUID> listClients;
    /**
     * 当前客户端连接中正在查看的房间有
     */
    private ConcurrentHashMap<String, Set<Long>> clientRoom;
    private static volatile ListClient listClient;

    private ListClient(){
        listClients = new CopyOnWriteArrayList<> ();
        clientRoom = new ConcurrentHashMap<>();
    }

    public static ListClient getInstance() {
        if (null == listClient){
            synchronized (ListClient.class){
                if (null == listClient){
                    listClient = new ListClient ();
                }
            }
        }
        return listClient;
    }

}
